from app import db

class SourceCodeInfo(db.Model):
    __tablename__ = 'source_code_info'

    id = db.Column(db.BigInteger, primary_key=True, autoincrement=True)
    number = db.Column(db.String(255), nullable=True)
    enter_url = db.Column(db.String(255), nullable=True)
    source_info = db.Column(db.String(500), nullable=True)
    domain_url = db.Column(db.String(255), nullable=True)
    http_url = db.Column(db.String(255), nullable=True)
    ip_white_list = db.Column(db.String(255), nullable=True)
    intercept_proxy = db.Column(db.Integer, default=0)
    intercept_computer = db.Column(db.Integer, default=0)
    intercept_ios = db.Column(db.Integer, default=0)
    intercept_android = db.Column(db.Integer, default=0)
    refuse_msg = db.Column(db.String(255), nullable=True)
    refuse_msg_c = db.Column(db.String(255), nullable=True)
    refuse_msg_d = db.Column(db.String(255), nullable=True)
    extend = db.Column(db.String(500), nullable=True)
    status = db.Column(db.Integer, default=0)

    def to_json(self):
        return {
            'id': self.id,
            'number': self.number,
            'enter_url': self.enter_url,
            'source_info': self.source_info,
            'domain_url': self.domain_url,
            'http_url': self.http_url,
            'ip_white_list': self.ip_white_list,
            'intercept_proxy': self.intercept_proxy,
            'intercept_computer': self.intercept_computer,
            'intercept_ios': self.intercept_ios,
            'intercept_android': self.intercept_android,
            'refuse_msg': self.refuse_msg,
            'refuse_msg_c': self.refuse_msg_c,
            'refuse_msg_d': self.refuse_msg_d,
            'extend': self.extend,
            'status': self.status
        }
